package br.com.agenda.controller;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class AppExceptionHandler {

	@ExceptionHandler(Throwable.class)
	public ModelAndView handleIOException(Throwable e) {

		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("error");
		modelAndView.addObject("appExceptionCode",
				"appExceptionCode: " + Math.random());
		modelAndView.addObject("exception", e);

		return modelAndView;
	}
}
